package com.shf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shf.domain.ResponseResult;
import com.shf.domain.entity.User;
import com.shf.domain.vo.NotificationsVo;
import com.shf.service.NotificationService;
import com.shf.service.UserService;
import com.shf.util.JwtUtil;
import com.shf.util.SecurityUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 叶枫
 * @date 2023/11/10.
 */
@Api(tags = "用户信息相关接口")
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private NotificationService notificationService;
    /**注入用户逻辑层*/
    @Autowired
    private UserService userService;

    /**
     * 个人信息
     * @return
     */
    @GetMapping("/userInfo")
    public ResponseResult userInfo(){
            return  userService.userInfo();
    }

    /**
     * 更新个人信息
     * @param user
     * @return
     */
    @PutMapping("userInfo")
    public ResponseResult  updateUserInfo(@RequestBody User user){
        //更新个人信息
        return userService.updateUserInfo(user);
    }

    /**
     * 注册用户
     * @param user
     * @return
     */
    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user){
        //注册功能
        return userService.register(user);
    }
    /**
     * 我的消息
     */
    @GetMapping("/getNotifications/{pageNum}/{pageSize}")
    public ResponseResult getNotifications(@PathVariable("pageNum") Integer pageNum,
                                           @PathVariable("pageSize") Integer pageSize){
       List notifications = notificationService.getNotifications(pageNum, pageSize);


       return ResponseResult.okResult(notifications);
    }


}
